<template>
  <div id="root" v-preventright>
    <router-view />
  </div>
</template>

<script>
import * as functions from '@/core/functions.js'
import crypto from '@/core/crypto.js'
import * as WindowType from '@/config/windowtype.js'
import VueFunctions from '@/core/VueFunctions.js'
export default {
  created () {
    // 消息提示框
    VueFunctions.method(WindowType.IFRAME_CONFIRM, (content, title, obj) => {
      this.$confirm(content, title, {
        distinguishCancelAndClose: obj && typeof obj.distinguishCancelAndClose === 'boolean' ? obj.distinguishCancelAndClose : true,
        showCancelButton: obj && typeof obj.showCancelButton === 'boolean' ? obj.showCancelButton : true,
        showConfirmButton: obj && typeof obj.showConfirmButton === 'boolean' ? obj.showConfirmButton : true,
        confirmButtonText: obj && obj.confirmButtonText ? obj.confirmButtonText : '确认',
        cancelButtonText: obj && obj.cancelButtonText ? obj.cancelButtonText : '取消',
        type: obj && obj.type ? obj.type : 'warning'
      }).then(() => {
        if (typeof obj.thenf === 'function') {
          obj.thenf()
        }
      }).catch((e) => {
        if (e === 'cancel' && typeof obj.catchf === 'function') {
          obj.catchf()
        }
      })
    })
    // 错误消息提示
    VueFunctions.method(WindowType.IFRAME_MESSAGE_ERROR, (content) => {
      this.$message.error(content)
    })
    // 获取资源链接
    VueFunctions.method(WindowType.REPERTORY_IMAGE_SRC, (param) => {
      param.hostId = this.$store.state.host.id
      return functions.getRepertoryImageSrc(param)
    })
    // 对iframe开放通过repertory数据生产后台可访问的资源路径
    VueFunctions.method(WindowType.REPERTORY_IMAGE_SRC_HREPERTORY, (repertory) => {
      return functions.getRepertoryImageSrcByHostRepertory(repertory)
    })
    // 对iframe开放通过repertory数据生产后台可访问的资源路径
    VueFunctions.method(WindowType.REPERTORY_VIDEO_SRC_HREPERTORY, (repertory) => {
      return functions.getRepertoryVideoSrcByHostRepertory(repertory)
    })
    // 加密方法
    VueFunctions.method(WindowType.CRYPTO_EN, (dataString) => {
      return crypto.en(dataString)
    })
    // 解密方法
    VueFunctions.method(WindowType.CRYPTO_DE, (secrteString) => {
      if (secrteString) {
        return crypto.de(secrteString)
      }
      return secrteString
    })
  },
  name: 'Root'
}
</script>

<style>
</style>
